package com.shizhanzhe.qdd.home.activity;

import android.annotation.SuppressLint;
import android.content.ClipboardManager;
import android.content.Context;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

import com.gyf.barlibrary.ImmersionBar;
import com.shizhanzhe.qdd.BuildConfig;
import com.shizhanzhe.qdd.R;
import com.shizhanzhe.qdd.base.UserBean;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class AboutActivity extends AppCompatActivity {

    @BindView(R.id.top_title)
    TextView topTitle;
    @BindView(R.id.tv_kf)
    TextView tvKf;
    @BindView(R.id.tv_gw)
    TextView tvGw;
    @BindView(R.id.tv_version)
    TextView tvVersion;
    private String kfwx = "";
    private String swwx = "";
    private String gw = "http://kaikaizc.cn";
    private ClipboardManager cm;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_about);
        ButterKnife.bind(this);
        ImmersionBar.with(this)
                .fitsSystemWindows(true)  //使用该属性,必须指定状态栏颜色
                .statusBarColor(R.color.colorAccent)
                .init();
        initData();
    }

    @SuppressLint("SetTextI18n")
    private void initData() {
        topTitle.setText("关于APP");
        tvVersion.setText(BuildConfig.VERSION_NAME);
        tvKf.setText("客服微信：" + UserBean.servicewx);
        tvGw.setText("官网：" + gw);
        kfwx = UserBean.servicewx;
//        Type type = ((ParameterizedType) getClass().getGenericSuperclass()).getActualTypeArguments()[0];
//        coop();
    }

    @OnClick({R.id.top_back, R.id.tv_kf, R.id.kfwx, R.id.tv_gw, R.id.gw})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.top_back:
                finish();
                break;
            case R.id.tv_kf:
            case R.id.kfwx:
                cm = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
                cm.setText(kfwx);
                Toast.makeText(this, "复制成功", Toast.LENGTH_SHORT).show();
                break;
            case R.id.tv_gw:
            case R.id.gw:
                cm = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
                Toast.makeText(this, "复制成功", Toast.LENGTH_SHORT).show();
                cm.setText(gw);
                break;
                default:
        }
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        ImmersionBar.with(this).destroy();
    }
}
